﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QQHelper;
using System.Web.Script.Serialization;

namespace QQ
{
    public class JsonHelper
    {
        /// <summary>
        /// 获取群信息
        /// </summary>
        /// <param name="jsonstr"></param>
        /// <returns></returns>
        public static QQGrouplist GetQQGroupList(string jsonstr)
        {
            jsonstr = jsonstr.Substring(10, jsonstr.Length - 12); // _Callback( 去掉
            JavaScriptSerializer js = new JavaScriptSerializer();
            QQGropJson grouplist = new QQGropJson();
            grouplist = js.Deserialize<QQGropJson>(jsonstr);
            return grouplist.data;
        }

        /// <summary>
        /// 群成员列表
        /// </summary>
        /// <param name="jsonstring"></param>
        /// <returns></returns>
        public static List<QQMember> GetMemberList(string jsonstring)
        {
            jsonstring = jsonstring.Substring(10, jsonstring.Length - 12); // _Callback( 去掉
            var js = new JavaScriptSerializer();
            QQGroup group = new QQGroup();
            group = js.Deserialize<QQGroup>(jsonstring);
            return group.data.item;
        }

        //解析json字符串返回群信息
        public static List<QQGroupInfo> GetGropList(string jsonstring)
        {
            var js = new JavaScriptSerializer();
            QQGropJson grouplist = new QQGropJson();
            grouplist = js.Deserialize<QQGropJson>(jsonstring);
            return grouplist.data.group;
        }
    }
}
